package cn.com.utt.common.message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

public class GetResp extends Message {
	@JSONField(name = "sn")
	private String sn;
	@JSONField(name = "data")
	private Object data;
	@JSONField(name = "error")
	private Fault Error;
	
	public GetResp() {
		setType(MessageType.GETRESP.toString());
	}

	@Override
	public String encode() {
		return JSON.toJSONString(this);
	}

	@Override
	public void decode(byte[] buf){
		GetResp getResp = JSON.parseObject(buf, GetResp.class);
		this.setId(getResp.getId());
		this.sn = getResp.getSn();
		this.data  = getResp.getData();
		this.Error = getResp.getError();
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Fault getError() {
		return Error;
	}

	public void setError(Fault error) {
		Error = error;
	}

}
